<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../util.js"></script>
    <style>
        div{
            width: 250px;
            height: 300px;
            position: absolute;
            left: -250px;
            top:300px;
            background: palevioletred;
            transition: 1s;
        }
        div span{
            width: 30px;
            height: 100px;
            position: absolute;
            right: -30px;
            top: 50px;
            background: palegreen;
            text-align: center;
            line-height: 34px;
        }
    </style>
</head>
<body>
    <div>
        <span>侧边栏</span>
    </div>
    <script>
        var div = document.querySelector('div')
        //JS结合CSS
        div.onmouseenter = function(){
            this.style.left = 0
        }
        div.onmouseleave = function(){
            this.style.left = '-250px'
        }
        
        //纯JS代码写
        // div.onmouseenter = function(){
        //     utils.move(div,'left',0,1000)
        // }
        // div.onmouseleave = function(){
        //     utils.move(div,'left',-250,1000)
        // }
    </script>
</body>
</html>